import { fetchCopyTask } from "@/api/task/index";

export default function() {
    return {
        data() {
            return {

            }
        },
        methods: {
            handleCopy({id}){
                this.$confirm('是否确认复制此任务?', '复制任务', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(async () => {
                    const res = await fetchCopyTask(id)
                    if(res.data.data){
                        this.$message({
                            type: 'success',
                            message: '复制成功!'
                        });
                        this.getList();
                    }else {
                        this.$message({
                            type: 'error',
                            message: '复制失败!'
                        });
                    }
                }).catch(() => {
                    this.$message({
                        type: 'info',
                        message: '已取消复制!'
                    });          
                });
            },
        }
    }
}